<template>
<div>
<div class="bai">
<el-form ref="form" :model="form" label-width="80px"  size="mini">
     <el-form-item label="查询名称" class="shu">
        <el-input v-model="form.name" placeholder="查询主治医师"></el-input>
        <el-button size="mini" type="primary" @click.native="dianj" >查找</el-button>
        <el-button size="mini" @click="ko">重置</el-button>
    </el-form-item>
</el-form>

  <el-table :data="data" stripe style="width: 100%;" size='medium'>
    <el-table-column prop="uname" border label="姓名" width="100"></el-table-column>
    <el-table-column prop="phone" label="手机号" width="150"> </el-table-column>
    <el-table-column prop="tim" label="日期" width="150"> </el-table-column>
    <el-table-column prop="ks" label="科室" width="100"> </el-table-column>
    <el-table-column prop="doctor" label="主治医师" width="100"> </el-table-column>
    <el-table-column prop="star" border label="评分" width="100"></el-table-column>
    <el-table-column prop="content" label="用户评论"></el-table-column>
    <el-table-column prop="state" label="操作" width="233">
      <template slot-scope="scope">
        <el-button type="success" size="mini"  @click="deleteRow(scope.$index)">删除该评论</el-button>
      </template>
    </el-table-column>
  </el-table>

  </div>
  </div>
</template>

<script>
export default {
  mounted(){
    this.getData()
  },
  methods:{
    getData(){
      this.axios.get(`/users/comment?doctor=${this.names}`).then(res=>{
        this.data = res.data.data
        console.log(res);
      })
    },
    //重置input输入框
    ko(){
      this.form.name = ''
      this.names=this.form.name
      this.getData()
    },
    dianj(){
      this.names=this.form.name
      this.getData()
    },
    //删除表格数据
    deleteRow(index) {
        this.$confirm('此操作将永久删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',  
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          
          let url = `/ht_delmo?cid=${this.data[index].cid}`
          this.axios.delete(url).then(res=>{
            console.log(res);
          })
        setTimeout(()=>{
           this.getData()
        },100)
          
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });   
        });

// 



    


      
    },

  },
  data() {
    return {
      names:'',
      datad:[],
      data:[],
         form: {
            name: '',
         },
    };
  },
};
</script>

<style lang="scss" scoped>
.bai{
  background-color: #fff;
  height: calc(100vh - 100px);
  overflow: hidden;
  overflow-x: hidden;
  overflow-y: scroll;
  box-shadow:0px 0px 10px #ccc;
  position: relative;
   border-radius: 7px;

}
.el-button{
    display: inline;
}
::v-deep .el-table{
  padding: 0 20px 20px 20px;
}
::v-deep .el-input__inner{
    width: 200px;
}
::v-deep .el-form{
  padding-top: 20px;
  padding-left: 10px;
}

::v-deep .el-input{
  width: 215px;
}
</style>




<style lang="scss">
.el-main {
  padding: 20px;
  
}
.el-table th.el-table__cell{
    background-color: #f5f5f5;
}.el-button{
    display: inline;
}
</style>


